﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy1_6
{
    public partial class Form1 : Form
    {
        private Font originalFont; 
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = "欢迎学习C#.NET: 需要认真学习才行。";

            originalFont = textBox1.Font;
        }
        private void buttonFormat_Click(object sender, EventArgs e)
        {
            textBox1.Font = new Font("隶书", 20);
        }

        private void buttonRestore_Click(object sender, EventArgs e)
        {
            textBox1.Font = originalFont;
        }

        private void buttonCopy_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox1.SelectedText))
            {
                textBox2.Text = textBox1.SelectedText;
                textBox2.Font = textBox1.Font;
            }
            else
            {
                MessageBox.Show("请先在文本框1中选择要复制的文本", "提示",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
